package com.phiyon.mytry.other;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;

import android.test.AndroidTestCase;
import android.util.Log;

public class AccessOtherAppPrivateTest extends AndroidTestCase {
	private static final String TAG = "AccessOtherAppPrivateTest";
	public void testAccessPrivate() throws Throwable {
		String path = "/data/data/com.phiyon.mytry.files/files/filetest.txt";
		File file = new File(path);
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		FileInputStream inStream = new FileInputStream(file);
		byte[] buffer = new byte[1024];
		int len = 0;
		while ( (len = inStream.read(buffer)) != 1 ){
			outStream.write(buffer, 0, len);
		}
		byte[] data = outStream.toByteArray();
		outStream.close();
		inStream.close();
		String content = new String(data);
		Log.i(TAG, content);
	}
	
	public void testAccessAppend() throws Throwable {
		String path = "/data/data/com.phiyon.mytry.files/files/append.txt";
		File file = new File(path);
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		FileInputStream inStream = new FileInputStream(file);
		byte[] buffer = new byte[1024];
		int len = 0;
		while ( (len = inStream.read(buffer)) != 1 ){
			outStream.write(buffer, 0, len);
		}
		byte[] data = outStream.toByteArray();
		outStream.close();
		inStream.close();
		String content = new String(data);
		Log.i(TAG, content);
	}
}
